package out_in_putStream;

import IO_Stream.Outputsream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

public class Outputstream {
    public static void main(String[] args) throws IOException{
        //write_utf_8();
        write_gbk();
    }

    private static void write_gbk() throws IOException{
        FileOutputStream fos = new FileOutputStream("C:\\Users\\啦啦啦\\Desktop\\c.txt",true);
        OutputStreamWriter osw = new OutputStreamWriter(fos,"gbk");
        //在创建的对象后面指定要使用的编码表名称
        osw.write("\r\n你好呀");
        osw.flush();
        osw.close();
    }

    private static void write_utf_8() throws IOException {
        FileOutputStream fos = new FileOutputStream("C:\\Users\\啦啦啦\\Desktop\\b.txt",true);
        OutputStreamWriter osw = new OutputStreamWriter(fos,"utf-8");
        //在创建的对象后面指定要使用的编码表名称
        osw.write("\r\n你好呀");
        osw.flush();
        osw.close();
    }
}
